#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:homework6_1.py
# author:wmf
# datetime:2021/4/16 22:46
# software: PyCharm
'''
this is function description
'''


# import module your need


# 一、定义一个狗类,里面有一个 列表成员变量(列表的元素是字典),
# 分别记录了 3种颜色的狗的颜色, 数量,和价格;
# 实现狗的买卖交易方法;
# 打印输出经过2-3次买卖方法后,剩下的各类狗的数量;


class dog:
    dog_type = []

    def __init__(self, color, count, price):
        self.dict = {"color": color, "count": count, "price": price}
        self.dog_type.append(self.dict)


def buy(d, color, count):
    for x in d.dog_type:
        if color == x["color"]:
            x["count"] = x["count"] - count


d1 = dog("黄色", 10, "200")
d2 = dog("黑色", 8, "400")
d3 = dog("白色", 7, "500")

print(dog.dog_type)
buy(dog, '黄色', 2)
buy(dog, '黑色', 1)
buy(dog, '白色', 3)
print(dog.dog_type)
